﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using SQLiteClient;
using System.IO.IsolatedStorage;

namespace Vanglen.YDLMSCP
{
    public partial class MainPage : PhoneApplicationPage
    {
        private string dbFileName = "db/sp.db";
        // 构造函数
        public MainPage()
        {
            InitializeComponent();

            Common.CopyContentToIsolatedStorage(dbFileName);
            Common.CopyContentToIsolatedStorage("db/sp.db-journal");

            using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (myIsolatedStorage.FileExists(dbFileName))
                {
                    SQLiteConnection db = new SQLiteConnection(dbFileName);
                    db.Open();
                    SQLiteCommand cmd = db.CreateCommand(" select * from caipu ");
                    object obj = cmd.ExecuteScalar();

                    db.Dispose();
                    db = null;
                }
            }
        }

        private void pList_Tap(object sender, GestureEventArgs e)
        {
            if (pList.SelectedIndex > -1)
                NavigationService.Navigate(new Uri(String.Format("/DetailList.xaml?d={0}", pList.SelectedIndex), UriKind.Relative));
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {

        }
    }
}